From 8bb6827483a645d5d2f978181c2d620553111249 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Tue, 10 Apr 2018 08:16:57 +0100 Subject: [PATCH] found a way to reuse SourceId::for_path in SourceId::from_cwd --- src/cargo/core/source/source_id.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/cargo/core/source/source_id.rs b/src/cargo/core/source/source_id.rs index 7bf6e63fc..784107c21 100644 --- a/src/cargo/core/source/source_id.rs +++ b/src/cargo/core/source/source_id.rs @@ -171,15 +171,13 @@ impl SourceId { /// /// Pass absolute path pub fn from_cwd(path: &Path) -> CargoResult { - let url = path.to_url()?; + let source_id = SourceId::for_path(path)?; + let source_id = Arc::try_unwrap(source_id.inner) + .map_err(|_| format_err!("failed to create SourceId from cwd `{}`", path.display()))?; Ok(SourceId { inner: Arc::new(SourceIdInner { - kind: Kind::Path, - canonical_url: git::canonicalize_url(&url)?, - url, - precise: None, - name: None, from_cwd: true, + ..source_id }), }) } -- 2.30.2